﻿#ifndef OPERATION_H
#define OPERATION_H

#include <QObject>
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include "device.h"
#include <QJsonObject>

class Operation : public QObject
{
    Q_OBJECT
public:
    explicit Operation(QObject *parent = nullptr);

protected:
    QString             m_strDeviceID;
    Device*             m_pDevice;
    QObject*            m_pParent;

signals:
    void                sendMessage(QString msg);

public:
    void                SetDevice(Device* pDevice){m_pDevice = pDevice;}
    void                SetDeviceId(QString strDeviceId){m_strDeviceID = strDeviceId;}

    Device*             GetDevice(){return m_pDevice;}
    QObject*            GetParent(){return m_pParent;}
    QString             GetDeviceId(){return m_strDeviceID;}

public:
    virtual void run() = 0;
    virtual Operation* clone(Operation* pOperation);
    virtual void writeXML(QXmlStreamWriter& writer) = 0;
    virtual void readFromXML(QXmlStreamReader& reader) = 0;

    virtual QString getClassName() = 0;

public:
    QString strDeviceID() const;
    void setStrDeviceID(const QString &newStrDeviceID);

signals:
};

#endif // OPERATION_H
